package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.networkassets.dict.ItNetworkAssetsDictFieldValue;
import com.glsc.ngateway.common.api.platform.dto.it.networkassets.dict.ItNetworkAssetsDictFieldValueDto;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class ItNetworkAssetsDictFieldValueConverter {

    public static ItNetworkAssetsDictFieldValueDto do2Dto(ItNetworkAssetsDictFieldValue valueDo) {
        return Objects.isNull(valueDo) ? null : ItNetworkAssetsDictFieldValueDto.builder()
                .id(valueDo.getId())
                .dictCode(valueDo.getDictCode())
                .dictFieldCode(valueDo.getDictFieldCode())
                .value(valueDo.getValue())
                .recordId(valueDo.getRecordId())
                .build();
    }

    public static List<ItNetworkAssetsDictFieldValueDto> do2Dto(List<ItNetworkAssetsDictFieldValue> valueDoList) {
        return CollectionUtils.isEmpty(valueDoList) ? java.util.Collections.EMPTY_LIST
                : valueDoList.stream().map(ItNetworkAssetsDictFieldValueConverter::do2Dto).collect(Collectors.toList());
    }

    public static ItNetworkAssetsDictFieldValue dto2Do(ItNetworkAssetsDictFieldValueDto valueDto) {
        return Objects.isNull(valueDto) ? null : ItNetworkAssetsDictFieldValue.builder()
                .id(valueDto.getId())
                .dictCode(valueDto.getDictCode())
                .dictFieldCode(valueDto.getDictFieldCode())
                .value(valueDto.getValue())
                .recordId(valueDto.getRecordId())
                .build();
    }

    public static List<ItNetworkAssetsDictFieldValue> dto2Do(List<ItNetworkAssetsDictFieldValueDto> valueDtoList) {
        return CollectionUtils.isEmpty(valueDtoList) ? java.util.Collections.EMPTY_LIST
                : valueDtoList.stream().map(ItNetworkAssetsDictFieldValueConverter::dto2Do).collect(Collectors.toList());
    }
}
